﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SafeScript.MetaModel.Statements
{
    public class FunctionOperator : Operator
    {
        public List<Parameter> Parameters = new List<Parameter>();
        public ITypeDef ReturnType;
        public StatementList Statements;
        public bool IsStatic;
        public bool IsIterator;

        public override ITypeDef ComputeType(ITypeDef goal, bool needsRef, ErrorReport report)
        {
            FunctionTypeDef t = new FunctionTypeDef();
            t.ReturnType = this.ReturnType;
            for (int i = 0; i < this.Parameters.Count; ++i)
                t.ParameterTypes.Add(this.Parameters[i].Type);
            return new InstanceType() { Type = t };
        }

        public override int GetPrecedence()
        {
            return 0;
        }
    }
}
